//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

public class demo_3340 {
    public demo_3340() {
    }

    public boolean isBalanced(String num) {
        char[] chars = num.toCharArray();
        int evenNumber = 0;
        int oddNumber = 0;

        for(int i = 0; i < chars.length; i += 2) {
            evenNumber += chars[i] - 48;
        }

        for(int i = 1; i < chars.length; i += 2) {
            oddNumber += chars[i] - 48;
        }

        return evenNumber == oddNumber;
    }

    public boolean isBalanced2(String num) {
        char[] chars = num.toCharArray();
        int evenNumber = 0;
        int oddNumber = 0;
        int i = 0;

        for(int j = 1; i < chars.length; j += 2) {
            evenNumber += chars[i] - 48;
            if (j < chars.length) {
                oddNumber += chars[j] - 48;
            }

            i += 2;
        }

        return evenNumber == oddNumber;
    }
}
